#include <board.h>
#include <rtthread.h>
#include "gpio_led.h"
#include "infrared.h"
void rt_led_thread_entry(void *parameter)
{
    while (1)
    {
        // LED_RED();
        // rt_thread_delay(300/RT_SLEEP_RATIO);
        // LED_BLUE();
        // rt_thread_delay(300/RT_SLEEP_RATIO);
        // LED_GREEN();
        if (infraled_byte_flag == RT_TRUE)
        {
            switch (get_infraled())
            {
            case 0:
                rt_kprintf("\t\tERROR!!! \n");
                break;
            case 162:
                rt_kprintf("\t\tPower On \n");
                break;
            case 226:
                rt_kprintf("\t\tMenu: \n");
                break;
            case 34:
                rt_kprintf("\t\tTest \n");
                break;
            case 2:
                rt_kprintf("\t\t+  \n");
                break;
            case 194:
                rt_kprintf("\t\tReturn \n");
                break;
            case 224:
                rt_kprintf("\t\t|<< \n");
                break;
            case 168:
                rt_kprintf("\t\t> \n");
                break;
            case 144:
                rt_kprintf("\t\t>>| \n");
                break;
            case 176:
                rt_kprintf("\t\tC \n");
                break;
            case 152:
                rt_kprintf("\t\t- \n");
                break;
            case 104:
                rt_kprintf("\t\t0 \n");
                break;
            case 48:
                rt_kprintf("\t\t1 \n");
                break;
            case 24:
                rt_kprintf("\t\t2 \n");
                break;
            case 122:
                rt_kprintf("\t\t3 \n");
                break;
            case 16:
                rt_kprintf("\t\t4 \n");
                break;
            case 56:
                rt_kprintf("\t\t5 \n");
                break;
            case 90:
                rt_kprintf("\t\t6 \n");
                break;
            case 66:
                rt_kprintf("\t\t7 \n");
                break;
            case 74:
                rt_kprintf("\t\t8 \n");
                break;
            case 82:
                rt_kprintf("\t\t9 \n");
                break;
            default:
                break;
            }
        }
        rt_thread_delay(1 / RT_SLEEP_RATIO);
    }
}

int rt_led_thread_init(void)
{
    rt_thread_t tid;

    tid = rt_thread_create("led",
                           rt_led_thread_entry, RT_NULL,
                           2048, RT_THREAD_PRIORITY_MAX / 3, 20);
    if (tid != RT_NULL) rt_thread_startup(tid);
}

INIT_APP_EXPORT(rt_led_thread_init);
